package com.zysstudy.web.config;

import com.zysstudy.service.IUserService;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;

import javax.annotation.Resource;
import java.security.Security;

/**
 * @author zhaoyoushui
 * @date 2025/6/24 17:07
 * @Description
 * @Copyright 南京优通信息科技股份有限公司
 */

@Configuration
@EnableWebFluxSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Resource
    IUserService userDetailService;

    @Bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }
//    @Bean
//    public SecurityFilterChain securityFilterChain(HttpSecurity http)  throws Exception{
////        http.authorizeHttpRequests(au)
//    }
    /**
     * 密码校验
     */

    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        auth.userDetailsService(userDetailService).passwordEncoder(new PasswordEncoder() {
//            @Override
//            public String encode(CharSequence charSequence) {
////                return SecureUtil.md5(charSequence.toString());
//                return null;
//            }
//
//            //密码匹配工作
//            @Override
//            public boolean matches(CharSequence rawPassword, String encodePassword) {
//                return rawPassword.equals(encodePassword);
//            }
//        })

    }

}
